<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="author" content="火星科技 http://mars3d.cn " />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="https://muyao1987.gitee.io/cdn/marsgis.cn/favicon/favicon.ico" />
    <title>GeoServer矢量服务查询(OGC WFS) | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>

    <!--第三方lib-->
    <script
      type="text/javascript"
      src="/lib/include-lib.js"
      libpath="/lib/"
      include="jquery,layer,toastr,font-awesome,web-icons,bootstrap,bootstrap-table,bootstrap-checkbox,layer,toastr,haoutil,mars3d"
    ></script>

    <link href="/css/style.css" rel="stylesheet" />
  </head>

  <body class="dark">
    <div id="mars3dContainer" class="mars3d-container"></div>

    <div class="infoview">
      <table class="mars-table">
        <tr>
          <td class="nametd">名称：</td>
          <td>
            <input id="queryText" type="text" placeholder="请输入查询关键字" value="" class="form-control" />
          </td>
        </tr>
        <tr>
          <td class="nametd">范围：</td>
          <td>
            <input type="button" class="btn btn-primary" value="框选范围" id="drawRectangle" />
            <input type="button" class="btn btn-primary" value="圆形范围" id="drawCircle" />
            <input type="button" class="btn btn-primary" value="多边形范围" id="drawPolygon" />
          </td>
        </tr>
        <tr>
          <td class="nametd">范围：</td>
          <td>
            <input type="button" class="btn btn-primary" value="查询" id="query" />
            <input type="button" class="btn btn-primary" value="清除" id="removeAll" />
          </td>
        </tr>
      </table>

      <div id="resultView" style="max-width: 500px; display: none">
        <table id="table" style="table-layout: fixed; word-break: break-all"></table>
      </div>
    </div>

    <script src="/js/common.js"></script>
    <script src="./map.js"></script>
    <script type="text/javascript">
      "use script" //开发环境建议开启严格模式

      let $table

      function initUI(options) {
        //框选查询 矩形
        $("#drawRectangle").click(function () {
          drawRectangle()
        })

        //框选查询   多边
        $("#drawPolygon").click(function () {
          drawPolygon()
        })

        //框选查询   圆
        $("#drawCircle").click(function () {
          drawCircle()
        })

        $("#removeAll").click(function () {
          clearAll()
          $("#resultView").hide()
        })

        $("#query").click(function () {
          $("#resultView").hide()
          let queryVal = $.trim($("#queryText").val())
          query(queryVal)
        })

        eventTarget.on("befortUI", (event) => {
          const dataSource = []
          event.list.forEach((item, index) => {
            dataSource.push({ key: index, name: item["项目名称"], type: item["设施类型"], address: item["具体位置"], graphic: item.graphic })
          })
          $table.bootstrapTable("load", dataSource)
          $("#resultView").show()
        })

        $table = $("#table")
        $table.bootstrapTable({
          height: 300,
          singleSelect: true, //单选
          iconsPrefix: "fa",
          pagination: true,
          showPaginationSwitch: false,
          pageNumber: 1,
          pageSize: 5,
          pageList: [5, 10, 20, 50, 100],
          columns: [
            {
              title: "", //序号
              sortable: false,
              align: "center",
              width: 50,
              formatter: function (value, row, index) {
                return index + 1
              }
            },
            {
              field: "name",
              title: "项目名称",
              sortable: true,
              align: "name",
              width: 100
            },
            {
              field: "type",
              title: "类型",
              sortable: true,
              align: "type",
              width: 100
            },
            {
              field: "address",
              title: "具体位置",
              align: "center",
              sortable: true,
              formatter: function (value, row) {
                if (value) {
                  return value
                } else {
                  return ""
                }
              }
            }
          ],
          onClickRow: function (item, $element, field) {
            let graphic = item.graphic
            if (graphic == null) {
              toastr.warning(item.name + " 无经纬度坐标信息！")
              return
            }

            graphic.openHighlight()

            graphic.flyTo({
              radius: 1000, //点数据：radius控制视距距离
              scale: 1.5, //线面数据：scale控制边界的放大比例
              complete: () => {
                graphic.openPopup()
              }
            })
          }
        })
      }
    </script>
  </body>
</html>
